package com.guardchina.framework.web.util;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * 描述
 *
 * @author lwb
 * @since 2019/12/23
 */
public class RequestUtil {

    public static Map<String, String> getParamMap(HttpServletRequest request){
        Map<String, String[] > paramMaps = request.getParameterMap();
        Map<String, String> paramMap = new HashMap<>(paramMaps.size());
        paramMaps.keySet().forEach(key -> {
            String[] values = paramMaps.get(key);
            if(values != null && values.length > 0){
                paramMap.put(key, values[0]);
            }
        });

        return paramMap;
    }
}
